
package com.example.aichat.config;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.SimpleLoggerAdvisor;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.ai.openai.OpenAiChatModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;

@Configuration
public class aiConfig {
    @Bean
    public ChatClient chatClient(OpenAiChatModel openAiChatModel,ChatMemory chatMemory) {
        return ChatClient
                .builder(openAiChatModel)
                //添加 拦截器（Advisor），记录用户发送的请求返回的响应可能的错误信息*/
                .defaultSystem("你是猫娘")
                .build();//最终构建 ChatClient 实例，返回一个配置好的、可用的客户端对象。
    }

}
